import { Profile, userinfo } from '@/types/data'
import { ProfileAction } from '@/types/store'
type UserProfile = { userinfo: Profile; profile: userinfo }
// 用户信息的reducer
function profile (
  state: UserProfile = { userinfo: {}, profile: {} } as UserProfile,
  action: ProfileAction
) {
  switch (action.type) {
    // 存储 用户信息
    case 'profile/user':
      return { ...state, userinfo: action.payload }
    // 用户个人信息
    case 'user/userinfo':
      return { ...state, profile: action.payload }

    default:
      return state
  }
}

export default profile
